package com.example.sport.controller;

import com.alibaba.fastjson.JSON;
import com.example.sport.pojo.MainMenu;
import com.example.sport.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
public class MenuController {

    @Autowired
    MenuService menuService;

    @RequestMapping("/menus")
    public String getMenus(){
        HashMap<String, Object> data = new HashMap<>();
        List<MainMenu> mainMenus = menuService.getMenus();
        data.put("data",mainMenus);
        data.put("status",200);
        String data_json = JSON.toJSONString(data);
        return data_json;
    }
}
